package com.hgt.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.ZoneId;
import java.time.ZonedDateTime;

/**
 * @Author: huanggaotao
 * @Description:
 * @Date: Created in 17:17 2021/6/24
 * @Modified By:
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customerRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("path_route_hgt",
                r->r.path("/guonei")
                .uri("http://news.baidu.com/guonei"))
                .build();

        //想要路由到另一个网站 就自己添加 新的路由构建
        routes.route("path_route_hgt1",
                r->r.path("/zhiboxx")
                .uri("https://www.lookae.com/?s=magicbullet+looks/")).build();
        return routes.build();


    }

    public static void main(String[] args) {
        ZonedDateTime shanghai = ZonedDateTime.now(ZoneId.of("Asia/Shanghai")); // 亚洲上海 +8 时区

        System.out.println(shanghai);
    }

}
